********************************************************************************
** 	TITLE: d4_mt_morris_educ_score_lvl.do
**
**	PROJECT: IGNITE
** 
**  PURPOSE: Figure IV: Pre- and Post-Test Performance

********************************************************************************
				set sortseed 13

		set scheme burd4
		graph set window fontface "Times New Roman" //makes times new roman the default

/*
Bar graph of distributions for both test scores
*/
******************************************************1.5X Balanced Sample
local ta reading math

local bta `""Reading""Math""'

local forder b a

local n : word count `ta'


forval tp= 1/`n'{
local t: word `tp' of `ta'
local bt: word `tp' of `bta'
local ordert: word `tp' of `forder'
use "$output_data/mt_morris_eudc_score_lvl.dta", clear
keep if `t'_gr_post !=. & `t'_gr_pre != .
qui su `t'_gr_post 
		local N=r(N)
		local mean : di %8.3f r(mean)
		local mean = subinstr("`mean'"," ","",.)
qui su `t'_gr_pre 
		local N1=r(N)
		local mean1 : di %8.3f r(mean)
		local mean1 = subinstr("`mean1'"," ","",.)
		
tw (kdensity `t'_gr_pre,  bwidth(1.5) lc(gs0) lwidth(medium) lp(--)) ///
			(kdensity `t'_gr_post, bwidth(1.5) lc(gs8) lwidth(medium) lp(solid)) ///
				, xlab(0(1)12, labsize(*.9)) xtitle("`bt' grade equivalent") ///
			xli(`mean1', lc(gs0) lwidth(*1.5) lp(-.)) ///
			xli(`mean', lc(gs8) lwidth(*1.5) lp(solid)) ///
			ytitle("Density") ylab(0(.05)0.2, labsize(*.9)) ///
		 	legend(order(1 "Pre-Test" 2 "Post-Test") lpattern(blank) position(6)) ysize(4) xsize(5.5)

gr export "$figures/figure4`ordert'_`t'_gr_dens.pdf", replace			
gr export "$figures/figure4`ordert'_`t'_gr_dens.tif",  width(1650) height(1200) replace //300 dpi
}
